import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2025-03-10
 * Time: 20:31
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n+1];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        arr[n] = 0;
        int[] bp = new int[n+1];
        bp[0] = arr[0];
        bp[1]=arr[1];
        for(int i=2;i<n+1;i++){
            bp[i]=Math.min(bp[i-1],bp[i-2])+arr[i];
        }
        System.out.println(bp[n]);
    }
}
